home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9642 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  33 lines

  1. Path: inforamp.net!ts1-10
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How can I include IOSTREAM.H only once?
  5. Date: Sun, 03 Mar 96 07:36:16 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4hbi55$899@sam.inforamp.net>
  8. References: <4gre90$oei@service.polymtl.ca>
  9. NNTP-Posting-Host: ts1-10.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <4gre90$oei@service.polymtl.ca>,
  13.    bluefox@info.polymtl.ca (Michael Gaudette) wrote:
  14. >I am presently engaged in what is usually called "the learning process", 
  15. >and I've been programming simple programs with classes.  Because of this, 
  16. >I have had to #include <iostream.h> in most of my "class.cpp" files AND 
  17. >in my main program. This (added to conio.h and all the other standard 
  18. >libraries) usually result in a simple program being 20000 lines long.
  19. >Is there any way (using Borland v4.5) to make the compiler only link 
  20. >those files ONCE?
  21.  
  22. Tell the preprocessor to include the file only if it has not already been 
  23. included.
  24.  
  25. #ifndef __IOSTREAM_H
  26. #include <iostream.h>
  27. #endif
  28.  
  29. But, this can sometimes generate unexpected errors/warnings/bugs.  So make 
  30. sure you know what you are doing when you use this technique.
  31.  
  32. Agrivar
  33.